<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	String id = request.getParameter("id");
    String s = request.getParameter("s");
    if(s==null){
    	s="";
    }
	if (id == null) {
		id = "";
	}
%>
<script type="text/javascript">
	var matendetailgrid;
	var id = $('#id').val();
	$(function() {

		matendetailgrid = $('#matendetailgrid')
				.datagrid(
						{
							//title : '商品列表',
							url : '${ctx}/maintenance/expense/detail/list?id='
									+ id,
							idField : 'id',
							frozenColumns : [ [ {
								width : '120',
								title : '商品名称',
								field : 'productname'

							} ] ],
							columns : [ [
							        {
							        	width : '100',
							        	title : '产品分类',
							        	field : 'pathname'
							        },
									{
										width : '80',
										title : '价格(元)',
										field : 'price'
									},
									{
										width : '80',
										title : '实际价额(元)',
										field : 'yfprice'
									},

									{
										width : '120',
										title : '添加时间',
										field : 'innertime'
									},
									{
										width : '100',
										title : '是否已供应货源',
										field : 'ispro',
										formatter : function(value, row, index) {
											switch (value) {
											case 0:
												return '未供应';
											case 1:
												return '已供应';
											}
										}
									},
									{
										width : '100',
										title : '操作',
										field : 'action',
										formatter : function(value, row) {
											var str = "";
											<% if(s==""){ %>
											if (row.ispro == 0) {
												str += sy
														.formatString(
																'<span onclick="updateHuo(\'{0}\');" style="margin-left:3px;cursor:pointer;">【{1}】</span>',
																row.id, "提供货源");
											}
											<%}%>
											return str;
										}
									} ] ],
							onBeforeLoad : function(param) {
								parent.$.messager.progress({
									text : '数据加载中....'
								});
							},
							onLoadSuccess : function(data) {

								parent.$.messager.progress('close');
							}

						});
	});

	//删除
	var updateHuo = function(id) {

		$.post('${ctx}/maintenance/expense/detail/update/' + id, {
			id : id
		}, function(data) {
			
			
			
			if (data.success)
				parent.$.messager.show({
					title : '温馨提示',
					msg : data.message
				});
			matendetailgrid.datagrid('reload');
		}, 'json');

	};
</script>
<!-- 界面布局  -->
<div class="easyui-layout" style="width: 100%; height: 100%;"
	data-options="fit:true,border:false">
	<input type="hidden" id="id" value="<%=id%>" />

	<div data-options="region:'center'" style="padding: 2px;">


		<div class="easyui-layout" data-options="fit : true,border : false">
			<div data-options="region:'center',border:false">
				<table id="matendetailgrid" data-options="fit:true,border:false"></table>
			</div>
		</div>
	</div>


</div>